package com.macro.mall.portal.controller;

import com.macro.mall.common.api.CommonResult;
import com.macro.mall.model.CmsSubject;
import com.macro.mall.model.PmsProduct;
import com.macro.mall.model.PmsProductCategory;
import com.macro.mall.portal.domain.AddPmsProductComment;
import com.macro.mall.portal.domain.HomeContentResult;
import com.macro.mall.portal.domain.PmsProductCommentRes;
import com.macro.mall.portal.service.CommentService;
import com.macro.mall.portal.service.HomeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 商品评价
 */
@Controller
@Api(tags = "PmsProductCommentController")
@Tag(name = "PmsProductCommentController", description = "商品评价管理")
@RequestMapping("/comment")
public class PmsProductCommentController {
    @Autowired
    private CommentService commentService;

    @ApiOperation("查询商品评价信息")
    @RequestMapping(value = "/selProductCommentData", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<PmsProductCommentRes> selProductCommentData(@RequestParam Long productId) {
        PmsProductCommentRes pmsProductCommentRes = commentService.selProductCommentData(productId);
        return CommonResult.success(pmsProductCommentRes);
    }


    @ApiOperation("发表评价")
    @RequestMapping(value = "/addProductCommentData", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<Void> addProductCommentData(@RequestBody AddPmsProductComment addPmsProductComment) {
        commentService.addProductCommentData(addPmsProductComment);
        return CommonResult.success(null);
    }


}
